package org.groupg.practice;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.util.Map;

public class JsoupExample5 {
    public static void main(String[] args) throws Exception {
        // 登录表单提交（示例网站）
        Connection.Response res = Jsoup.connect("https://example.com/login")
                .data("username", "myUser", "password", "pass123")
                .method(Connection.Method.POST)
                .execute();

        // 获取登录后的 Cookie（用于后续会话）
        Map<String, String> cookies = res.cookies();

        // 访问需要登录的页面
        Document dashboard = Jsoup.connect("https://example.com/dashboard")
                .cookies(cookies)
                .get();

        System.out.println(dashboard.title());
    }
}